import React, { useEffect } from 'react'
// import axios from 'axios';
import instance from '@utils/request';
import { Duanzis } from '@/api/types';
export default function DuanziCom() {

  useEffect(() => {
    let getDuanzi = async () => {
      //请求获取结果
      // instance.get<any, Duanzis>('/duanzi')
      // .then(v => {
      //   v.forEach(item => {
      //     console.log(item.name);
      //   })
      // })

      //await 的写法
      // axios.get 第二个泛型参数, 设置的是 get 返回 promise 对象成功结果值的类型
      let result = await instance.get<any, Duanzis>('/duanzi');
      result.forEach(item => {
        console.log(item.name)
      })
    }
    getDuanzi()
  }, [])

  return (
    <div>03_DuanziCom</div>
  )
}
